package com.xjt.sentinel.controller.flow;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.cluster.client.codec.data.FlowRequestDataWriter;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletResponse;
import java.nio.charset.StandardCharsets;
import java.security.PublicKey;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: xu
 * @Description: TODO
 * @Date: 2021/11/14 17:19
 */
@RestController
public class flowController
{
	@GetMapping("/getFlow")
	@SentinelResource(value = "getFlow",blockHandler = "SentinelFlow")
	public String testFlow(HttpServletResponse response)
	{
		return "返回一个正常得数据";
	}

	public String SentinelFlow(BlockException e)
	{
		e.printStackTrace();
		return "service appear flow impose";
	}

}
